package com.sumer.psychology.common.resource;

import com.sumer.psychology.common.application.ApplicationServiceRegistry;
import com.sumer.psychology.common.domain.model.User;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

/**
 * 授权
 * <p/>
 * Created by twer on 15/3/8.
 */
@Path("/v1/auth/")
public class AuthResource extends AbstractResource {
    @GET
    @Path("userId/")
    @Produces(MediaType.APPLICATION_JSON)
    public Response findUserId() {
        String userId = currentUserId();
        User currentUser = ApplicationServiceRegistry
                .userService()
                .userFrom(userId);
        return Response.ok(currentUser).build();
    }
}
